#define _CRT_SECURE_NO_WARNINGS  1


#include <stdio.h>

struct TreeNode
{
    struct TreeNode* left;
    struct TreeNode* right;
    int val;
};

struct TreeNode* CreatTree(char* a, int* pi)
{
    if (a[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }

    struct TreeNode* root = (struct TreeNode*)malloc(sizeof(struct TreeNode));

    root->val = a[(*pi)++];
    root->left = CreatTree(a, pi);
    root->right = CreatTree(a, pi);

    return root;

}

void InOrder(struct TreeNode* root)
{
    if (root == NULL)
        return;

    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}

int main() {
    char a[100] = { 0 };
    scanf("%s", a);
    int i = 0;
    struct TreeNode* root = CreatTree(a, &i);
    InOrder(root);
    return 0;
}